<!--
 * @Description:
 * @Author: cgt
 * @Date: 2021-12-23 14:05:56
 * @LastEditors: cgt
 * @LastEditTime: 2021-12-28 19:56:15
-->
<template>
  <div>
    <el-button @click="searchByLocation">获取行政区划</el-button>
    <el-button @click="getRegionName">获取省市区名称</el-button>
    <el-button @click="getRegionCode">获取省市区编号</el-button>
  </div>
</template>

<script>
import mixins from '../mixins';
export default {
  name: 'DistrictTool',
  props: {
    getTool: {
      type: Function,
      required: true
    }
  },
  mixins: [mixins],
  data() {
    return {};
  },
  methods: {
    async searchByLocation() {
      let geometry = this.getTool('BaseMapTool').getBounds();
      let msg = await this.getTool('DistrictTool').searchByLocation(geometry);
      this.showMessage(msg);
    },
    async getRegionName() {
      let geometry = this.getTool('BaseMapTool').getBounds();
      let msg = await this.getTool('DistrictTool').getRegionName(geometry);
      this.showMessage(msg);
    },
    async getRegionCode() {
      let geometry = this.getTool('BaseMapTool').getBounds();
      let msg = await this.getTool('DistrictTool').getRegionCode(geometry);
      this.showMessage(msg);
    },
    showMessage(msg) {
      this.$alert(msg, '信息', { confirmButtonText: '确定' });
    }
  }
};
</script>

<style scoped></style>
